package com.iris.live.services.data.repositories;

import com.iris.live.services.data.models.CarTransferLogModel;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface CarTransferLogRepository
		extends JpaRepository<CarTransferLogModel, Integer>, JpaSpecificationExecutor<CarTransferLogModel> {

//	@Modifying
//    @Query("delete from CarTransferLogModel a where a.stockCode = ?1")
//    void deletByStockCode(Integer stockCode);

//    @Modifying
//	@Query("update CarTransferLogModel a set a.stockOutDate = ?2, a.stockOutUser = ?3,a.modifyDate=?4 where a.id = ?1")
//	int updateByStockCode(Integer stockCode, Date stockOutDate, String stockOutUser, Timestamp ts);

    @Query("select a from CarTransferLogModel a where a.stockCode=?1 order by a.id desc")
    List<CarTransferLogModel> findByStockId(Integer storeId);

	@Query("select a from CarTransferLogModel a where a.id=?1")
	CarTransferLogModel findById(Integer id);

    @Query("select a from CarTransferLogModel a where a.stockCode=?1 and a.type=?2 ")
    List<CarTransferLogModel> findByStoreIdAndType(Integer storeId, Integer type);
}
